package com.hmall.api.client;


import com.hmall.api.client.fallback.ItemClientFallbackFactory;
import com.hmall.api.config.DefaultFeigenConfig;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

@FeignClient(value = "item-service",
        configuration = DefaultFeigenConfig.class,

        // ItemClientFallbackFactory 生效
        fallbackFactory = ItemClientFallbackFactory.class
)
//声明服务名称,configuration = DefaultFeigenConfig.classd 日志级别
public interface ItemClient {

    @GetMapping("/items")
        //声明请求方式   声明请求路径
    List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids); //返回值类型 声明请求参数


    @PutMapping("/items/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);
}
